package water.utils;


import app.nbdevices.utils.ConvertUtil;
import water.entity.WaterCycleReport;
import water.modle.codecModle.WaterReport;
import water.modle.revModle.RevWaterReportData;

public class    WaterDataDecode {
    public static WaterReport WaterReportDataDecode(String resData){
        byte[] res= ConvertUtil.getBase64Codec().decode(resData);
     //   byte[] res=ConvertUtil.decoder.decode("AAAAAAEAAAAAAAADiYYRGCgwCEJBNwAPPAAZEgQTJQAAyM8AAAAAyFPfdwfmxA3dAAAAAAAAAAAAAAAAAA87OAAPOzgADzs4AA87OAAPOzgADzs4AA87OAAPOzgADzs4AA87OAAPOzgADzwAAA88AAAPPAAADzwAAA87nAAPO5wADzwAAA88AAAPPAAADzwAAA88AAAPPAAADzwA");
        WaterReport waterReport=new WaterReport();
        waterReport.setLogicAddr(ConvertUtil.arraySub(res,5,11));
        waterReport.setICCID(ConvertUtil.arraySub(res,12,21));
        waterReport.setCurrentData(ConvertUtil.arraySub(res,22,25));
        waterReport.setTime(ConvertUtil.arraySub(res,26,31));
        waterReport.setInterval(ConvertUtil.arraySub(res,32,33));
        waterReport.setStatus(res[34]);
        waterReport.setDemolition(res[35]);
        waterReport.setDemolitionState(res[36]);
        waterReport.setSwingValve(res[37]);
        waterReport.setIntervalSwing(res[38]);
        waterReport.setSoftVersion(res[39]);
        waterReport.setCellId(ConvertUtil.arraySub(res,40,43));
        waterReport.setTxPower(res[44]);
        waterReport.setSnr(res[45]);
        waterReport.setRssi(res[46]);
        waterReport.setSengType(res[47]);
        waterReport.setAutoCloseNum(ConvertUtil.arraySub(res,48,51));
        waterReport.setWarnCloseNum(ConvertUtil.arraySub(res,52,55));
        waterReport.setAtuoSwitch(res[56]);
        waterReport.setCacheDataTime(ConvertUtil.arraySub(res,57,59));
        waterReport.setPerHourData(ConvertUtil.arraySub(res,60,155));
        return waterReport;
    }

    public static void main(String[] args) {
        RevWaterReportData waterRepMsg=null;
        WaterReport waterReport = WaterReportDataDecode("AAAAAAEAACAZERF3iYYRGSZgB4gmNgAAAGQgBCYIVwAFoM8AAAAAlFBXiQzm+gXdAAAAAAAAAAAAAAAAAAAAZAAAAGQAAABkAAAAZAAAAGQAAABkAAAAZAAAAGQAAABkAAAAZAAAAGQAAABkAAAAZAAAAGQAAABkAAAAZAAAAGQAAABkAAAAZAAAAGQAAABkAAAAZAAAAGQAAABk");
        WaterCycleReport waterCycleReport = WaterExplain.exEleCycle(waterReport);
        System.out.println(waterCycleReport);
        // System.out.println(WaterDataDecode(waterRepMsg));
    }
}
